import java.lang.reflect.Constructor;

import edu.ucla.cs.typecast.event.EventListener;
import edu.ucla.cs.typecast.event.EventManager;
import edu.ucla.cs.typecast.event.EventSink;
import edu.ucla.cs.typecast.event.EventSource;


public class NewsSubscriber implements EventListener{

    /**
     * @param args
     */
    public static void main(String[] args) {
        try { 
            for(int i=0; i<args.length; i++) { 
                Class newsClass = Class.forName(args[i]);
                EventSink eventSink = EventManager.getInstance().getEventSink(newsClass); 
                eventSink.addEventListener(new NewsSubscriber(), null);  
            }
        } catch(Throwable t) { 
            t.printStackTrace(); 
        }
    }

    public void notify(Class[] types, Object event, Object handback) { 
        System.out.println("Receive " + types[0].getName() + " with content " + ((News)event).getContent()); 
    }

    
}
